﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using BSCMFF.Core.DataLayer;

namespace BSCMFF.Web.Pages
{
    public partial class TaskList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            l.Text = "now";
        }

        protected void RadGrid1_DeleteCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
            UserControl taskDetail = (UserControl)editedItem.FindControl(GridEditFormItem.EditFormUserControlID);

            int task_ID = Convert.ToInt32(editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["Task_ID"].ToString());

            BSCEntities context = new BSCEntities();
            var task = (from t in context.Tasks
                        where t.Task_ID == task_ID
                        select t).Single();

            context.DeleteObject(task);
            context.SaveChanges();
        }
    }
}